package com.yunban.project.template.controller;

import com.yunban.project.template.model.dto.PersonalizedConfigReq;
import com.yunban.project.template.model.vo.PersonalizedConfigResp;
import com.yunban.project.template.service.PersonalizedConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lijiajun
 * @date: 2025-02-13
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "个性化配置模块")
@RequestMapping("/personalized-config-api")
public class PersonalizedConfigController {

    @Resource
    private PersonalizedConfigService personalizedConfigService;

    @GetMapping("/infos")
    @Operation(summary = "获取个性化配置")
    List<PersonalizedConfigResp> getPersonalizedConfigInfos() {
        return personalizedConfigService.getPersonalizedConfigInfos();
    }

    @PostMapping
    @Operation(summary = "保存个性化配置")
    Boolean savePersonalizedConfig(@RequestBody PersonalizedConfigReq req) {
        return personalizedConfigService.savePersonalizedConfig(req);
    }

    @PutMapping("/{id}")
    @Operation(summary = "修改个性化配置")
    Boolean editPersonalizedConfig(@PathVariable long id, @RequestBody PersonalizedConfigReq req) {
        return personalizedConfigService.editPersonalizedConfig(id, req);
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除个性化配置")
    Boolean removePersonalizedConfig(@PathVariable long id) {
        return personalizedConfigService.removePersonalizedConfig(id);
    }
}
